package cate.game.play.skill.passive.gem;

import cate.common.table.d.GDSkill;
import cate.game.play.base.TargetFilterParam;
import cate.game.play.base.TargetSelector;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 攻击时，有 80% 概率获得 1 点杀意，叠加到 4 层时，对敌方全体目标造成 47% 攻击比例的真实伤害
 */
public class 杀意PH extends PassiveHandler {

	private int 概率;

	private int buff;

	private int 层数;

	private double 伤害系数;

	//概率=？？&buff=？？&层数=？？&伤害系数=4700
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		概率 = args.getInt("概率", 0);
		buff = args.getInt("buff", 0);
		层数 = args.getInt("层数", 0);
		伤害系数 = args.getWDouble("伤害系数", 0d);
	}

	@Override
	public void onSkillDone(SkillActionCtx action) {
		if (!action.getSkill().cfg.isHurtSkill()) {
			return;
		}
		int i = skill.owner.buff.tryAddByTid(action, skill.owner, buff, 概率);
		if (i > 0) {
			int buffNum = skill.owner.buff.countBuffByTid(buff);
			if (buffNum >= 层数) {
				skill.owner.buff.removeBuffByTid(action, buff);
				double damage = skill.owner.attr.attTotal() * 伤害系数;
				TargetFilterParam param = new TargetFilterParam().targetNumSet(6);
				for (Fighter fighter : TargetSelector.doFind(skill.owner, action.getTeamVs(), param)) {
					fighter.attr.passiveHurt(action, skill.owner, damage, GDSkill.Nature.REAL);
				}
			}
		}
	}
}
